puts(¨string¨) // print DEFINES #define C (int) #define X(i) x[i] #define Y(i,j) i * j C X(3) + Y(i,7); gets transformed into the code (int) x[3] + i * 7; #define abc(x,y) # x "+" # y abc(123,xyz) --> "123+xyz" espaco --> ## COMMENT between #if 0 and #endif lines. char str[] = "292348"; // a char array with 7 elements (why?); str[0] = 'T' is ok char *pstr = "2983"; // a string literal; *pstr = '4' gives a runtime error char str[20] = "AB"; // same as char str[20] = { 'A','B',0 }; or char str[20] = { 65,66,0 }; defines a string that can hold up to 19 characters (space must be reserved for the 0 terminator), initialized with the two character string AB. value name meaning escape sequence 0 NUL null character (end of string) \0 7 BEL terminal bell \a 8 BS backspace \b 9 HT horizontal tab \t 10 LF new line \n 12 FF form feed (new page) \f 13 CR carriage return \r 27 ESC escape \e int a[100]; int *pa = &a[30]; // same as int *pa = a + 30; //acede ao a[30] int *pA = &a[-2]; // same as int *pA = a - 2; STRUCT struct dot d; // a dot structure (RESERVES SPACE FOR THE STRUCTURE) struct dot *pd; // a pointer to a dot structure (DOES NOT RESERVE SPACE FOR THE STRUCTURE) pd = &d; // set the pointer to point to the structure (now it can be safely used) d.x = 3; // set the x field to 3 pd->color = 5; // set the color field to 5 d.next = NULL; // set the next field to NULL (a special address that points to nothing) enum color { black,red,green,blue = 4 }; // can have 4 values: black, red, green, and blue, respectively with numerical values 0, 1, 2, and 4. sizeof(1 + 2) is the number of bytes needed to store the result of the expression 1 + 2 extern int global_var; // variable that may, or may not, be defined in the same source code file static int global_var; // global variable that is visible only to the functions of the same source code file SLIDE 49